<%@page import="java.net.URLEncoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<jsp:useBean id="db" class="ctm.javacode.dbBean"/>
<jsp:useBean id="Pagination" class="ctm.javacode.pagination"/>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>中醫體質評量系統</title>
<script language="Javascript" type="text/javascript" src="./JQuery/checkID.js"></script> 
<script language="Javascript" type="text/javascript">
function confirm(category){
	var personId = document.getElementById("personId").value;
	var role = document.getElementById("role").value
	document.getElementById("category").value = category;
	if (personId == ""){
		alert("你未填寫身分證字號!");
		return;
	}else{
		if(checkID(personId)){
			document.getElementById("personId").value = personId;
			document.form1.submit();	
		}		
		else{
			document.getElementById("personId").value = "";
			ClearStatus();
			return;
		}
	}			
}
</script>
<style type="text/css">
<!--
body {
	background-image: url(img/grass.jpg);
    background-position: center top;
	background-color: #FFFFFF;
	background-repeat: repeat;
}
body,td,th {
	color: #000000;
	font-size:24px;
	font-family: Arial;
}


a:link {
font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color: #1B4001;
}
a:visited {
	font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color:#1B4001;
}
a:hover {
font-family:Arial; 
	font-size:25px;
	text-decoration:none;
	color:#000000;
}


.ind:link {
	color: #FFFFFF;
	text-decoration:none;
	font-family:"Arial";
	font-size:20px;
	background-color: #437A27;
}
.ind:visited {
color:#FFFFFF;
text-decoration:none;
font-family:"Arial";
font-size:20px;
background-color: #437A27;
}

.ind:hover {
color:#000000;
text-decoration:none;
font-family:"Arial";
font-size:20px;
background-color: #437A27;
}

.HEAD_STYLE {
	font-weight:bold;
	color: #1B4001;
	font-family:"標楷體";
	font-size:30px; 
}
.TEXT_STYLE {
	font-family:Arial;
	color:#193940;
	font-size:24px;
	font-weight:bold;
}
.BOTTOM_STYLE {
	color: #FFFFFF; 
	font-family: Arial; 
	font-size:20px;
}
.LEFT_BUTTON {
	font-family:"標楷體"; 
	font-size:30px;
}
.button
{
	border:1px;
	padding-top: 4px;
	padding-right: 7px;
	padding-bottom: 4px;
	padding-left: 7px;
	background-color: #468129;
	color: #FFFFFF;
	font-size: 16px;
	border-color: #3C7023;
}
-->
</style>

</head>

<body alink="#FF0000" vlink="#FF0000">
<form name="form1" action="showQuestionnaire.jsp" method="post">
<%
    int curPages = Pagination.curPages(Pagination.strPage(request,"page")); //Pagination.strPage(request,"page")取page值傳遞給curPages()方法
    Pagination.setRows(10); //設置每頁顯示10條
    int totalPage = 1 ;
%>
<%
    db.setDataSource("jdbc/ctmpllab");
	db.Connected();
	String name = (String)request.getSession().getAttribute("login");
	String filename ="";
	String category ="";
	String sqlQuery = "select categoryname from categoryTable order by id desc";	 
	ResultSet rs;
	rs = db.ExcuteQuery(sqlQuery) ;	
	rs.last();
	int resultCount = rs.getRow() ;
	rs.beforeFirst();
	totalPage = Pagination.getPages(resultCount);	
	ResultSet rsTen = Pagination.getPageSet(rs, curPages);
		
		%>
<table width="100%" border="0">
		<tr>
			<td><p>&nbsp;</p></td>
		</tr>
				
			
			
		
 
    		<td width="5%">&nbsp;</td>
			
			<td bgcolor="#FFFFFF"><table width="100%" border="0">
      			<tr>
        			<td background="img/herbal.jpg"> 
						<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
          				<p>&nbsp;</p>
		  				<p>&nbsp;</p>
          
          			</td>
			  </tr>
     
	 
	 
	 
	  			  <tr>
        			<td>	
						<table bgcolor="#437A27" width="100%" border="0">
         					 <tr>
            					<td>&nbsp;</td>
								<td width="20%" align="center"><a  class="ind" href="main.jsp" target="_parent">回到主選單</a></td> 
												
           			 			
          			 		</tr>
        				</table>
					</td>
     			  </tr>
      
	  			
	  
	
	  
	 			  <tr>
        				<td>
							<table width="100%">
           						<tr>
									<td valign="top">
										<table width="100%">
											<tr><td class="TEXT_STYLE" align="center">
											<input type="hidden" name="role"  id="role" value="<%= name %>"/>
											<% if (request.isUserInRole("admin")|| request.isUserInRole("professional")) { %>
											<span>身分證字號</span>&nbsp;<input type="text" name="personId"  id="personId" value="" maxlength="10" />
											<!--  <input type="hidden" id="temp"></input>-->
											</td></tr>
											<% }else{ %>
												<input type="hidden" name="personId"  id="personId" value="a123456789"/>
											<% }%>
											<input type="hidden" name="category" id="category" value="體質類型"/>
											
											<tr>
												<td class="HEAD_STYLE" align="center">請選擇要填寫的問卷類型</td>
													
											</tr>
											
											<tr>
												<td >
												 	<table border="1" align="center" width="50%">
											  	<tr>
	    
	    										<td class="TEXT_STYLE" align="center">問卷類型</td>
	  										   </tr>
											
											  <%int i=1;%>
	    
	    									<%while (rsTen.next() && i <= 10 ){%>
	 										   <tr>
	 										    <%category = rsTen.getString("categoryname");%>
											    <td align="center"><a href="javascript: confirm('<%= category %>')">依<%= category%>問卷</a></td>		
											    </tr>
											    <%
												    i=i+1;	    
	    
														    }
	 										   %> 
												 
											 </table>
											 <%
%>
<p align="center">
<%if(curPages>1){%>
<a href="questionnaire.jsp?page=<%=curPages-1%>" style="background-color:#ffffff;">上一頁</a>
<%}%>
<%if(curPages<totalPage){%>
<a href="questionnaire.jsp?page=<%=curPages+1%>" style="background-color:#ffffff;">下一頁</a>
<%}%></p>	
												</td>
													
											</tr>
											
											<tr>
												<td align="center"><input type="button" value="回到主選單" 
												onclick="window.location='main.jsp'" class="button" /></td>
											</tr>
										</table>
									
            

		
											
								  </td>
									

								</tr>
       					 </table>
         

         				</td>
			  </tr>
   
	  
					 <tr>
      					  
   					    <td><p>&nbsp;</p></td>
  					 </tr>
	  				
					<tr>
      					  <td bgcolor="#437A27"><div align="center" class="BOTTOM_STYLE">Copyright@ITRI and CCU_PLlab</div></td>
			  </tr>
    						
  	 			  
	
			</table>
		</td>
	    
		<td width="5%">&nbsp;</td>
</table>
<p>&nbsp;</p>
</form>
</body>
</html>
